
var MongoClient=require('mongodb').MongoClient;
var dbpath='mongodb://localhost:27017'
var dbname='lcyblog'

function dbConnect(collectName){
   var p=new Promise(function(resolve,reject){
    MongoClient.connect(dbpath,function(error,dbCon){
        if(error) reject(error);
        //连接特定的数据库
        var db=dbCon.db(dbname)
        //查找数据
        db.collection(collectName,function(error,coll){
          if(error) reject(error);
            resolve({coll,dbCon})
        })
          
        
    })
   })
   return p;

}
module.exports=dbConnect